// source --> https://sakinahoutreach.org/wp-content/plugins/sd-donations/assets/js/crowdfunding.js var Crowdfunding = {}; var delay = (function(){ var timer = 0; return function(callback, ms){ clearTimeout (timer); timer = setTimeout(callback, ms); }; })(); Crowdfunding.Campaign = ( function($) { var customPriceField, priceOptions, submitButton, currentPrice, startPledgeLevel; var formatCurrencySettings = {}; function priceOptionsHandler() { customPriceField.keyup(function() { var price = $( this ).asNumber( formatCurrencySettings ); delay( function() { if ( price < startPledgeLevel ) Crowdfunding.Campaign.findPrice( startPledgeLevel ); else Crowdfunding.Campaign.findPrice( price ); }, 1000); }); priceOptions.click(function(e) { var pledgeLevel = $(this), price = Crowdfunding.Campaign.parsePrice( $(this) ); if ( pledgeLevel.hasClass( 'inactive' ) ) return; $(this).find( 'input[type="radio"]' ).attr( 'checked', true ); customPriceField .val( price ) .formatCurrency( formatCurrencySettings ); }); } return { init : function() { formatCurrencySettings = { 'decimalSymbol' : atcfSettings.campaign.currency.decimal, 'digitGroupSymbol' : atcfSettings.campaign.currency.thousands, 'symbol' : '' } currentPrice = 0; customPriceField = $( '#contribute-modal-wrap #atcf_custom_price' ); priceOptions = $( '#contribute-modal-wrap .atcf-price-option' ); submitButton = $( '#contribute-modal-wrap a.edd-add-to-cart' ); Crowdfunding.Campaign.setBasePrice(); priceOptionsHandler(); }, findPrice : function( price ) { var foundPrice = { price : 0, el : null }; customPriceField .val( price ) .formatCurrency( formatCurrencySettings ); currentPrice = price; priceOptions.each( function( index ) { var price = price = Crowdfunding.Campaign.parsePrice( $(this) ); var pledgeLevel = parseFloat( price ); if ( ( currentPrice >= pledgeLevel ) && ! $( this ).hasClass( 'inactive' ) ) { var is_greater = pledgeLevel > foundPrice.price; if ( is_greater ) { foundPrice = { price : pledgeLevel, el : $(this) } } } }); foundPrice.el.find( 'input[type="radio"]' ).attr( 'checked', true ); }, setBasePrice : function() { var basePrice = { price : 1000000000, // something crazy el : null } priceOptions.each( function( index ) { if ( ! $( this ).hasClass( 'inactive' ) ) { var price = Crowdfunding.Campaign.parsePrice( $(this) ); if ( parseFloat( price ) < parseFloat( basePrice.price ) ) { basePrice = { price : price, el : $( this ) } } } }); startPledgeLevel = parseFloat( basePrice.price ); if ( null != basePrice.el ) basePrice.el.find( 'input[type="radio"]' ).attr( 'checked', true ); if ( atcfSettings.campaign.isDonations != 1 ) { customPriceField .val( startPledgeLevel ) .formatCurrency( formatCurrencySettings ); } }, parsePrice : function( el ) { var price = el.data( 'price' ); price = price.split( '-' ); price = price[0]; return price; } } }(jQuery)); Crowdfunding.SubmitCampaign = ( function($) { function addReward() { var rewardContainer = $( '.atcf-submit-campaign-rewards' ); var reward = rewardContainer.find( 'div:last-of-type' ); $( '.atcf-submit-campaign-add-reward-button' ).click(function(e) { e.preventDefault(); var newReward = reward.clone(); var count = rewardContainer.find( '.atcf-submit-campaign-reward' ).length; newReward.removeClass( 'static' ); newReward.find( 'input:not([type=hidden]), select, textarea' ).val( '' ); newReward.find( 'input, select, textarea' ).each(function() { var label = $( this ).prev().attr( 'for' ); var name = $( this ).attr( 'name' ); name = name.replace( /\[(\d+)\]/, '[' + parseInt( count ) + ']'); if ( label ) { label = label.replace( /\[(\d+)\]/, '[' + parseInt( count ) + ']'); } $( this ) .attr( 'name', name ) .attr( 'id', name ) .attr( 'readonly', false ); $( this ).prev() .attr( 'for', label ); newReward.insertBefore( $( '.atcf-submit-campaign-add-reward' ) ).show(); }); }); } function removeReward() { $( 'body' ).on( 'click', '.atcf-submit-campaign-reward-remove a', function(e) { e.preventDefault(); var reward = $( this ).parents( '.atcf-submit-campaign-reward' ); var rewardContainer = $( '.atcf-submit-campaign-rewards' ); var count = rewardContainer.find( '.atcf-submit-campaign-reward' ).length; if ( count == 1 || reward.hasClass( 'static' ) ) return alert( atcfSettings.submit.i18n.oneReward ); reward.remove(); }); } function endDate() { $( '.atcf-toggle-neverending' ).click(function(e) { e.preventDefault(); $( 'input[id="length"]' ).attr( 'disabled', ! $( 'input[id="length"]' ).attr( 'disabled' ) ); }); if ( $( '.atcf-toggle-neverending' ).hasClass( 'active' ) ) $( '.atcf-toggle-neverending' ).trigger( 'click' ); } return { init : function() { addReward(); removeReward(); endDate(); $( '#norewards' ).click(function() { $( '.atcf-submit-campaign-rewards' ).toggle(); }); if ( $( '#norewards' ).is( ':checked' ) ) { $( '.atcf-submit-campaign-rewards' ).hide(); } } } }(jQuery)); jQuery(document).ready(function($) { if ( atcfSettings.pages.is_submission ) Crowdfunding.SubmitCampaign.init(); if ( atcfSettings.pages.is_campaign ) Crowdfunding.Campaign.init(); }); // source --> https://sakinahoutreach.org/wp-content/themes/helpinghands/wp-advanced-search/js/scripts.js // Global constants var __WPAS = { FORM : "#wp-advanced-search.wpas-ajax-enabled", CONTAINER : "#wpas-results", INNER : "#wpas-results-inner", DEBUG_CONTAINER : "#wpas-debug", PAGE_FIELD : "#wpas-paged", FORM_ID: "", KEY_PREFIX: "wpasInstance_", HASH: "", STORAGE_KEY: function() { return this.KEY_PREFIX + this.FORM_ID; } }; jQuery(document).ready(function($) { __WPAS.FORM_ID = $('#wpas-id').val(); __WPAS.HASH = $(__WPAS.FORM).data('ajax-url-hash'); var CURRENT_PAGE = 1; /** * Event listeners */ $('form.wpas-autosubmit :input').change(function() { $(this).parents('form').submit(); }); $('button.wpas-clear').click(function(e) { e.preventDefault(); $(this).parents('form').find(':input') .not(':button, :submit, :reset, :hidden') .val('') .removeAttr('checked') .removeAttr('selected'); $(this).parents('form.wpas-autosubmit').each(function() { $(this).submit(); return false; }); }); $('input.wpas-reset').click(function(e){ e.preventDefault(); $(this).parents('form')[0].reset(); $(this).parents('form.wpas-autosubmit').each(function() { $(this).submit(); return false; }); }); /** * AJAX Functionality */ if ($(__WPAS.FORM).length == 0) { log("No AJAX-enabled WPAS search form detected on page."); return; } if ($(__WPAS.CONTAINER).length == 0) { log("No container with ID #wpas-results found on page. Results cannot be shown"); return; } var DEBUG_ON = ($(__WPAS.FORM).hasClass('wpas-debug-enabled')) ? true : false; var SHOW_DEFAULT = ($(__WPAS.FORM).data('ajax-show-default')) ? true : false; var T = (DEBUG_ON) ? 500 : 0; if (DEBUG_ON && $(__WPAS.DEBUG_CONTAINER).length == 0) { log("WPAS_DEBUG is enabled but no container with ID #wpas-debug was found " + "on this page. Debug information cannot be shown."); return; } var ajaxLoader = { container: "wpas-load", load_btn: "wpas-load-btn", load_btn_text: "", load_img: "wpas-loading-img", load_img_url: "", init : function(form) { this.load_btn_text = $(form).data('ajax-button'); this.load_img_url = $(form).data('ajax-loading'); $(__WPAS.CONTAINER).append(this.create()); }, create: function() { var html = "